package agile.hustler.activities;

import java.util.Scanner;

import agile.hustler.Battle.Battle;
import agile.hustler.Characters.Tank;
import agile.hustler.activities.R;
import agile.hustler.activities.R.layout;
import android.app.Activity;
import android.content.Intent;
import android.content.pm.ActivityInfo;
import android.graphics.Typeface;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.os.Handler;
import android.widget.ImageView;
import android.widget.TextView;

public class FightSplashBot extends Activity {
    /** Called when the activity is first created. */
    private final int SPLASH_DISPLAY_LENGHT = 3000;

    TextView txtName01, txtName02;
    Drawable charIcon1, charIcon2;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setRequestedOrientation(ActivityInfo.SCREEN_ORIENTATION_PORTRAIT);
        
        
        setContentView(R.layout.fightsplash);
        

        Bundle b = getIntent().getExtras();
        final String data = b.getString("key");
        final int whichKindOfBot = b.getInt("key2");
        

        Typeface face=Typeface.createFromAsset(getAssets(), "fonts/SEVERINA.ttf");
        
        txtName01 = (TextView) findViewById(R.id.PlayerName01);
        txtName02 = (TextView) findViewById(R.id.PlayerName02);
        
        txtName01.setTypeface(face);
        txtName02.setTypeface(face);
        
        Scanner scanner = new Scanner(data);
 	   scanner.useDelimiter(" ");
 	   String type = scanner.next();
 	   String name = scanner.next();
 	   
 	   txtName01.setText(name);
 	   //Player face
 	  charIcon1 = getResources().getDrawable(R.drawable.dpssmallr);
 	  
 	  if(type.toUpperCase().equals("TANK"))
 	 {
 		 charIcon1 = getResources().getDrawable(R.drawable.tanksmallr);
 	 }
 	  else if(type.toUpperCase().equals("CASTER"))
  	 {
  		 charIcon1 = getResources().getDrawable(R.drawable.castersmallr);
  	 }

      ImageView imView1 = (ImageView)findViewById(R.id.PlayerFace01);
		imView1.setBackgroundDrawable(charIcon1);
		
	  //Bot face
		charIcon2 = getResources().getDrawable(R.drawable.dpssmalll);
	 	  txtName02.setText("Dps Bot");
	 	  if(whichKindOfBot == 1)
	 	 {
	 		 charIcon2 = getResources().getDrawable(R.drawable.tanksmalll);
	 		txtName02.setText("Tank Bot");
	 	 }
	 	  else if(whichKindOfBot == 2)
	  	 {
	  		 charIcon2 = getResources().getDrawable(R.drawable.castersmalll);
	  		txtName02.setText("Caster Bot");
	  	 }

	      ImageView imView2 = (ImageView)findViewById(R.id.PlayerFace02);
			imView2.setBackgroundDrawable(charIcon2);
		
		
        /* New Handler to start the Menu-Activity
         * and close this Splash-Screen after some seconds.*/
        new Handler().postDelayed(new Runnable(){
            public void run() {
                  /* Create an Intent that will start the Menu-Activity. */
            	Bundle B = new Bundle();

      		  B.putString("key", data);
      		  B.putInt("key2", whichKindOfBot);
      		  
      		  Intent intent = new Intent(FightSplashBot.this, FightSetupBot.class);

      		  intent.putExtras(B);
      		  
      		  startActivity(intent);
      		  finish();
      		System.gc();
            }
      }, SPLASH_DISPLAY_LENGHT);
        
    }
}